<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;

        }
        .ad{
            position: relative;
            margin: 100px auto;
            width: 700px;
            height: 400px;
            background: url('r.jpg') no-repeat center/100% 100%;
            /* display: none; */
        }
        .ad .close{
            position: absolute;
            top: 5px;
            right: 5px;
            width: 30px;
            height: 50px;
            border: 1px solid rgb(255, 102, 0);
            font-size: 32px;
        }
    </style>
</head>
<body>
    <div class="ad">1</div>
    <div class="ad">2</div>
    <div class="ad">3
        <!-- 这是注释语句 -->
        
        <h3 class="close">X</h3>
        <h3 class="close2">X</h3>
        <h3 class="close3">X</h3>
        
    </div>
    <script>
        //获取类名ad的元素节点
        const a = document.querySelectorAll('.ad');
        let list = a[1].nextElementSibling.children;
        console.log(list[0]);
    </script>
    <script>
        //关闭元素节点
        const clo = document.querySelector('.close');
        //获取类名ad的元素节点
        const ad = document.querySelector('.ad');
        //给关闭按钮添加监听事件
        clo.addEventListener('click',function(){
            //事件处理程序
            clo.parentElement.style.display = 'none';
            //ad[2].style.display = 'none';
        },false);

        console.log(clo.parentNode);
        console.log(clo.parentElement);
        console.log('----------------');
        //console.log(ad[2].childNodes); 
        //console.log(ad[2],children);
        console.log('----------------');
        console.log(clo.previousElementSibling);
        console.log(clo.nextElementSibling);

    </script>
</body>
</html>